package m.store.model;

import m.base.model.StoreInfo;
import m.common.model.*;
import m.common.model.type.FieldType;
import m.common.model.util.ModelQueryList;
import m.common.model.util.QueryCondition;

import java.util.List;
import java.util.stream.Collectors;

@TableMeta(name="ts_store_number",description="商户编号")
public class StoreNumber extends Model implements MigrationModel {
    @Override
    public List<String> migrationOidList(String storeOid) throws Exception {
        return ModelQueryList.getModelList(this.getClass(),new String[]{"oid"},null,
                        QueryCondition.eq("store.oid",storeOid))
                .stream().map(Model::getOid).collect(Collectors.toList());
    }
    @LinkTableMeta(name="store_oid",table= StoreInfo.class,description="所属商户")
    private StoreInfo store;
    @FieldMeta(name="type",type= FieldType.STRING,description="类型",dictOption = "R:入库,C:出库,F:付款,S:收款,P:生产,U:盘点,Z:期初")
    private String type;
    public final static String Type_Stock="R";
    public final static String Type_Sale="C";
    public final static String Type_Pay="F";
    public final static String Type_Income="S";
    public final static String Type_Produce="P";
    public final static String Type_Count="U";
    public final static String Type_Begin="Z";
    @FieldMeta(name="year_month_str",type= FieldType.STRING,length = 10,description="年月")
    private String yearMonth;
    @FieldMeta(name="max_number",type= FieldType.INT,description="最大数字")
    private Integer maxNumber;

    public StoreInfo getStore() {
        return store;
    }

    public void setStore(StoreInfo store) {
        this.store = store;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getYearMonth() {
        return yearMonth;
    }

    public void setYearMonth(String yearMonth) {
        this.yearMonth = yearMonth;
    }

    public Integer getMaxNumber() {
        return maxNumber;
    }

    public void setMaxNumber(Integer maxNumber) {
        this.maxNumber = maxNumber;
    }
}
